//
//  ZYClientVC.m
//  MerChant_car
//
//  Created by STAR on 2017/11/22.
//  Copyright © 2017年 陈越. All rights reserved.
//

#import "ZYClientVC.h"
#import "ZYSelectViewController.h"
#import "ZYSelectVCModel.h"
#import "ZYClientCell.h"

static NSString *identifier = @"ZYClientCell";

@interface ZYClientVC ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic, strong) UIButton *titleButton;
@property (nonatomic, strong) UITableView *tableView;
@end

@implementation ZYClientVC
- (UIButton *)titleButton {
    if (!_titleButton) {
        _titleButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_titleButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [_titleButton setTitle:@"入场客户" forState:UIControlStateNormal];
        [_titleButton sizeToFit];
        [_titleButton addTarget:self action:@selector(selectType) forControlEvents:UIControlEventTouchUpInside];
    }
    return _titleButton;
}
- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.frame)) style:UITableViewStylePlain];
        _tableView.dataSource = self;
        _tableView.delegate = self;
        _tableView.rowHeight = 60;
//        [_tableView registerClass:[ZYClientCell class] forCellReuseIdentifier:identifier];
        [_tableView registerNib:[UINib nibWithNibName:identifier bundle:nil] forCellReuseIdentifier:identifier];
    }
    return _tableView;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.titleView = self.titleButton;
    [self.view addSubview:self.tableView];
}
//MARK:选择不同需求
- (void)selectType {
    ZYSelectViewController *vc = [[ZYSelectViewController alloc]initWithNibName:@"ZYSelectViewController" bundle:nil];
    vc.dataSoucreArray = @[@"入场客户",@"我的客户"];
    vc.cModel.presentFrame = CGRectMake(0, 64, self.view.frame.size.width, 120);
    [self presentViewController:vc animated:YES completion:nil];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 3;
    return self.dataSoureArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    ZYClientCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier forIndexPath:indexPath];
    return cell;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

@end
